package com.project.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.project.bean.TicketBean;
import com.project.mapper.ITicketMapper;
import com.project.service.ITicketService;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
@Transactional
public class TicketServiceImpl implements ITicketService {
    @Autowired
    private ITicketMapper ticketMapper;

    @Override
    public IPage<TicketBean> findByItem(Integer pageNO, String movieName, String cinema, String seriesName, String row) {
        QueryWrapper<TicketBean> qw = new QueryWrapper<>();
        if (movieName != null && movieName.length() != 0) {
            qw.like("t_movieName", movieName);
        }
        if (cinema != null && cinema.length() != 0) {
            qw.like("t_cinema", cinema);
        }
        if (seriesName != null && seriesName.length() != 0) {
            qw.like("t_seriesName", seriesName);
        }
        if (row != null && row.length() != 0) {
            qw.like("t_row", row);
        }

        return ticketMapper.selectPage(new Page<>(pageNO, 3), qw);
    }
    @Override
    public TicketBean getById(Integer id){
        return ticketMapper.selectById(id);
    }
}
